
% Default to the notebook output style

    


% Inherit from the specified cell style.




    
\documentclass[11pt]{article}

    
    
    \usepackage[T1]{fontenc}
    % Nicer default font (+ math font) than Computer Modern for most use cases
    \usepackage{mathpazo}

    % Basic figure setup, for now with no caption control since it's done
    % automatically by Pandoc (which extracts ![](path) syntax from Markdown).
    \usepackage{graphicx}
    % We will generate all images so they have a width \maxwidth. This means
    % that they will get their normal width if they fit onto the page, but
    % are scaled down if they would overflow the margins.
    \makeatletter
    \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
    \else\Gin@nat@width\fi}
    \makeatother
    \let\Oldincludegraphics\includegraphics
    % Set max figure width to be 80% of text width, for now hardcoded.
    \renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=.8\maxwidth]{#1}}
    % Ensure that by default, figures have no caption (until we provide a
    % proper Figure object with a Caption API and a way to capture that
    % in the conversion process - todo).
    \usepackage{caption}
    \DeclareCaptionLabelFormat{nolabel}{}
    \captionsetup{labelformat=nolabel}

    \usepackage{adjustbox} % Used to constrain images to a maximum size 
    \usepackage{xcolor} % Allow colors to be defined
    \usepackage{enumerate} % Needed for markdown enumerations to work
    \usepackage{geometry} % Used to adjust the document margins
    \usepackage{amsmath} % Equations
    \usepackage{amssymb} % Equations
    \usepackage{textcomp} % defines textquotesingle
    % Hack from http://tex.stackexchange.com/a/47451/13684:
    \AtBeginDocument{%
        \def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code
    }
    \usepackage{upquote} % Upright quotes for verbatim code
    \usepackage{eurosym} % defines \euro
    \usepackage[mathletters]{ucs} % Extended unicode (utf-8) support
    \usepackage[utf8x]{inputenc} % Allow utf-8 characters in the tex document
    \usepackage{fancyvrb} % verbatim replacement that allows latex
    \usepackage{grffile} % extends the file name processing of package graphics 
                         % to support a larger range 
    % The hyperref package gives us a pdf with properly built
    % internal navigation ('pdf bookmarks' for the table of contents,
    % internal cross-reference links, web links for URLs, etc.)
    \usepackage{hyperref}
    \usepackage{longtable} % longtable support required by pandoc >1.10
    \usepackage{booktabs}  % table support for pandoc > 1.12.2
    \usepackage[inline]{enumitem} % IRkernel/repr support (it uses the enumerate* environment)
    \usepackage[normalem]{ulem} % ulem is needed to support strikethroughs (\sout)
                                % normalem makes italics be italics, not underlines
    

    
    
    % Colors for the hyperref package
    \definecolor{urlcolor}{rgb}{0,.145,.698}
    \definecolor{linkcolor}{rgb}{.71,0.21,0.01}
    \definecolor{citecolor}{rgb}{.12,.54,.11}

    % ANSI colors
    \definecolor{ansi-black}{HTML}{3E424D}
    \definecolor{ansi-black-intense}{HTML}{282C36}
    \definecolor{ansi-red}{HTML}{E75C58}
    \definecolor{ansi-red-intense}{HTML}{B22B31}
    \definecolor{ansi-green}{HTML}{00A250}
    \definecolor{ansi-green-intense}{HTML}{007427}
    \definecolor{ansi-yellow}{HTML}{DDB62B}
    \definecolor{ansi-yellow-intense}{HTML}{B27D12}
    \definecolor{ansi-blue}{HTML}{208FFB}
    \definecolor{ansi-blue-intense}{HTML}{0065CA}
    \definecolor{ansi-magenta}{HTML}{D160C4}
    \definecolor{ansi-magenta-intense}{HTML}{A03196}
    \definecolor{ansi-cyan}{HTML}{60C6C8}
    \definecolor{ansi-cyan-intense}{HTML}{258F8F}
    \definecolor{ansi-white}{HTML}{C5C1B4}
    \definecolor{ansi-white-intense}{HTML}{A1A6B2}

    % commands and environments needed by pandoc snippets
    % extracted from the output of `pandoc -s`
    \providecommand{\tightlist}{%
      \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
    \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
    % Add ',fontsize=\small' for more characters per line
    \newenvironment{Shaded}{}{}
    \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
    \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
    \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
    \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
    \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
    \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
    \newcommand{\RegionMarkerTok}[1]{{#1}}
    \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
    \newcommand{\NormalTok}[1]{{#1}}
    
    % Additional commands for more recent versions of Pandoc
    \newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{{#1}}}
    \newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{{#1}}}
    \newcommand{\ImportTok}[1]{{#1}}
    \newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{{#1}}}}
    \newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{{#1}}}
    \newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
    \newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{{#1}}}
    \newcommand{\BuiltInTok}[1]{{#1}}
    \newcommand{\ExtensionTok}[1]{{#1}}
    \newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{{#1}}}
    \newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{{#1}}}
    \newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    
    
    % Define a nice break command that doesn't care if a line doesn't already
    % exist.
    \def\br{\hspace*{\fill} \\* }
    % Math Jax compatability definitions
    \def\gt{>}
    \def\lt{<}
    % Document parameters
    \title{Algorithm}
    
    
    

    % Pygments definitions
    
\makeatletter
\def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax%
    \let\PY@ul=\relax \let\PY@tc=\relax%
    \let\PY@bc=\relax \let\PY@ff=\relax}
\def\PY@tok#1{\csname PY@tok@#1\endcsname}
\def\PY@toks#1+{\ifx\relax#1\empty\else%
    \PY@tok{#1}\expandafter\PY@toks\fi}
\def\PY@do#1{\PY@bc{\PY@tc{\PY@ul{%
    \PY@it{\PY@bf{\PY@ff{#1}}}}}}}
\def\PY#1#2{\PY@reset\PY@toks#1+\relax+\PY@do{#2}}

\expandafter\def\csname PY@tok@w\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.73,0.73}{##1}}}
\expandafter\def\csname PY@tok@c\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@cp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.74,0.48,0.00}{##1}}}
\expandafter\def\csname PY@tok@k\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kt\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.69,0.00,0.25}{##1}}}
\expandafter\def\csname PY@tok@o\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@ow\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\expandafter\def\csname PY@tok@nb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@nf\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\expandafter\def\csname PY@tok@nc\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\expandafter\def\csname PY@tok@nn\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\expandafter\def\csname PY@tok@ne\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.82,0.25,0.23}{##1}}}
\expandafter\def\csname PY@tok@nv\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@no\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.53,0.00,0.00}{##1}}}
\expandafter\def\csname PY@tok@nl\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.63,0.63,0.00}{##1}}}
\expandafter\def\csname PY@tok@ni\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.60,0.60,0.60}{##1}}}
\expandafter\def\csname PY@tok@na\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.49,0.56,0.16}{##1}}}
\expandafter\def\csname PY@tok@nt\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@nd\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\expandafter\def\csname PY@tok@s\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@sd\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@si\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}}
\expandafter\def\csname PY@tok@se\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.13}{##1}}}
\expandafter\def\csname PY@tok@sr\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}}
\expandafter\def\csname PY@tok@ss\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@sx\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@m\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@gh\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\expandafter\def\csname PY@tok@gu\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.50,0.00,0.50}{##1}}}
\expandafter\def\csname PY@tok@gd\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.63,0.00,0.00}{##1}}}
\expandafter\def\csname PY@tok@gi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.63,0.00}{##1}}}
\expandafter\def\csname PY@tok@gr\endcsname{\def\PY@tc##1{\textcolor[rgb]{1.00,0.00,0.00}{##1}}}
\expandafter\def\csname PY@tok@ge\endcsname{\let\PY@it=\textit}
\expandafter\def\csname PY@tok@gs\endcsname{\let\PY@bf=\textbf}
\expandafter\def\csname PY@tok@gp\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\expandafter\def\csname PY@tok@go\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}}
\expandafter\def\csname PY@tok@gt\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.27,0.87}{##1}}}
\expandafter\def\csname PY@tok@err\endcsname{\def\PY@bc##1{\setlength{\fboxsep}{0pt}\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}
\expandafter\def\csname PY@tok@kc\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kd\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kn\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kr\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@bp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@fm\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\expandafter\def\csname PY@tok@vc\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@vg\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@vi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@vm\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@sa\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@sb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@sc\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@dl\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@s2\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@sh\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@s1\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@mb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@mf\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@mh\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@mi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@il\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@mo\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@ch\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@cm\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@cpf\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@c1\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@cs\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}

\def\PYZbs{\char`\\}
\def\PYZus{\char`\_}
\def\PYZob{\char`\{}
\def\PYZcb{\char`\}}
\def\PYZca{\char`\^}
\def\PYZam{\char`\&}
\def\PYZlt{\char`\<}
\def\PYZgt{\char`\>}
\def\PYZsh{\char`\#}
\def\PYZpc{\char`\%}
\def\PYZdl{\char`\$}
\def\PYZhy{\char`\-}
\def\PYZsq{\char`\'}
\def\PYZdq{\char`\"}
\def\PYZti{\char`\~}
% for compatibility with earlier versions
\def\PYZat{@}
\def\PYZlb{[}
\def\PYZrb{]}
\makeatother


    % Exact colors from NB
    \definecolor{incolor}{rgb}{0.0, 0.0, 0.5}
    \definecolor{outcolor}{rgb}{0.545, 0.0, 0.0}



    
    % Prevent overflowing lines due to hard-to-break entities
    \sloppy 
    % Setup hyperref package
    \hypersetup{
      breaklinks=true,  % so long urls are correctly broken across lines
      colorlinks=true,
      urlcolor=urlcolor,
      linkcolor=linkcolor,
      citecolor=citecolor,
      }
    % Slightly bigger margins than the latex defaults
    
    \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
    
    

    \begin{document}
    
    
    \maketitle
    
    

    
    \subsection{第一部分：获取生猪价格序列，对数据进行分类整理}\label{ux7b2cux4e00ux90e8ux5206ux83b7ux53d6ux751fux732aux4ef7ux683cux5e8fux5217ux5bf9ux6570ux636eux8fdbux884cux5206ux7c7bux6574ux7406}

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}1}]:} \PY{k+kn}{import} \PY{n+nn}{pandas} \PY{k}{as} \PY{n+nn}{pd}
        \PY{k+kn}{import} \PY{n+nn}{numpy} \PY{k}{as} \PY{n+nn}{np}
\end{Verbatim}


    ① \textbf{数据读入}

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}2}]:} \PY{c+c1}{\PYZsh{} 1、读取数据}
        \PY{n}{rawFile} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{read\PYZus{}csv}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{生猪月度价格历史统计表.csv}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{header}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{,} \PY{n}{encoding}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{utf\PYZhy{}8}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
        \PY{c+c1}{\PYZsh{} 2、数据空值处理(数据清洁将省略；如果有控制提示用户重新更改数据)}
        \PY{n}{flag} \PY{o}{=} \PY{k+kc}{True}
        \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{rawFile}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}\PY{p}{:}
            \PY{k}{if}\PY{p}{(}\PY{n}{rawFile}\PY{o}{.}\PY{n}{iloc}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{n}{i}\PY{p}{]}\PY{o}{.}\PY{n}{isna}\PY{p}{(}\PY{p}{)}\PY{o}{.}\PY{n}{sum}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{:}
                \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{第}\PY{l+s+s1}{\PYZsq{}}\PY{o}{+} \PY{n+nb}{str}\PY{p}{(}\PY{n}{i}\PY{p}{)} \PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{列日期有空值\PYZti{}！请检测并确认格式后，重新运行此行\PYZti{}！}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
                \PY{n}{flag} \PY{o}{=} \PY{k+kc}{False}
                \PY{k}{break}
            \PY{k}{elif}\PY{p}{(}\PY{n}{rawFile}\PY{o}{.}\PY{n}{iloc}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{n}{i}\PY{p}{]}\PY{o}{.}\PY{n}{isnull}\PY{p}{(}\PY{p}{)}\PY{o}{.}\PY{n}{sum}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{:}
                \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{第}\PY{l+s+s1}{\PYZsq{}}\PY{o}{+} \PY{n+nb}{str}\PY{p}{(}\PY{n}{i}\PY{p}{)} \PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{列价格有null数据\PYZti{}！请检测并确认格式后，重新运行此行\PYZti{}！}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
                \PY{n}{flag} \PY{o}{=} \PY{k+kc}{False}
                \PY{k}{break}
        \PY{k}{if} \PY{n}{flag}\PY{p}{:}
            \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{数据完整，可以使用\PYZti{}！}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
            \PY{c+c1}{\PYZsh{} 3、将数据转换为list形式，第一组为日期列表，第二组为价格列表}
            \PY{n}{dateData} \PY{o}{=} \PY{n}{rawFile}\PY{o}{.}\PY{n}{iloc}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{]}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}
            \PY{n}{priceData} \PY{o}{=} \PY{n}{rawFile}\PY{o}{.}\PY{n}{iloc}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{]}\PY{o}{.}\PY{n}{round}\PY{p}{(}\PY{l+m+mi}{4}\PY{p}{)}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
数据完整，可以使用\textasciitilde{}！

    \end{Verbatim}

    ② \textbf{分解后的数据样式}

    -\textgreater{} 日期数组

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}3}]:} \PY{n+nb}{print}\PY{p}{(}\PY{n}{dateData}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
[200607, 200608, 200609, 200610, 200611, 200612, 200701, 200702, 200703, 200704, 200705, 200706, 200707, 200708, 200709, 200710, 200711, 200712, 200801, 200802, 200803, 200804, 200805, 200806, 200807, 200808, 200809, 200810, 200811, 200812, 200901, 200902, 200903, 200904, 200905, 200906, 200907, 200908, 200909, 200910, 200911, 200912, 201001, 201002, 201003, 201004, 201005, 201006, 201007, 201008, 201009, 201010, 201011, 201012, 201101, 201102, 201103, 201104, 201105, 201106, 201107, 201108, 201109, 201110, 201111, 201112, 201201, 201202, 201203, 201204, 201205, 201206, 201207, 201208, 201209, 201210, 201211, 201212, 201301, 201302, 201303, 201304, 201305, 201306, 201307, 201308, 201309, 201310, 201311, 201312, 201401, 201402, 201403, 201404, 201405, 201406, 201407, 201408, 201409, 201410, 201411, 201412, 201501, 201502, 201503, 201504, 201505, 201506, 201507, 201508, 201509, 201510, 201511, 201512, 201601, 201602, 201603, 201604, 201605, 201606, 201607, 201608, 201609, 201610, 201611, 201612, 201701, 201702, 201703, 201704, 201705, 201706, 201707, 201708, 201709, 201710, 201711, 201712, 201801, 201802, 201803, 201804, 201805, 201806, 201807, 201808, 201809, 201810, 201811, 201812, 201901, 201902, 201903, 201904, 201905, 201906, 201907, 201908, 201909, 201910, 201911, 201912, 202001, 202002, 202003, 202004, 202005, 202006, 202007, 202008, 202009, 202010, 202011, 202012, 202101, 202102, 202103, 202104, 202105, 202106, 202107, 202108, 202109, 202110, 202111]

    \end{Verbatim}

    -\textgreater{} 价格数组

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}4}]:} \PY{n+nb}{print}\PY{p}{(}\PY{n}{priceData}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
[7.26, 7.61, 8.424, 8.184, 9.19, 9.984, 10.02, 9.106, 8.92, 9.779, 12.037, 12.639, 14.929, 13.757, 12.96, 13.203, 15.145, 16.335, 16.819, 17.309, 17.397, 16.805, 15.84, 15.55, 14.68, 14.1, 12.15, 11.83, 12.02, 13.55, 13.386, 11.58, 10.66, 10.08, 9.59, 10.58, 11.29, 12.15, 11.92, 11.37, 12.02, 12.78, 11.64, 10.35, 9.63, 10.01, 9.7, 10.37, 12.84, 12.68, 12.79, 13.44, 14.29, 13.61, 14.06, 15.04, 15.01, 15.14, 16.89, 19.61, 19.29, 19.68, 19.15, 17.49, 16.56, 17.25, 17.56, 16.08, 14.77, 14.41, 13.8, 14.11, 13.88, 14.64, 14.74, 14.46, 15.31, 16.46, 17.18, 14.7, 12.77, 12.32, 13.91, 14.4, 15.09, 16.05, 15.87, 15.55, 15.77, 15.38, 12.35, 11.92, 10.77, 10.55, 13.37, 13.01, 13.97, 15.35, 14.52, 13.78, 13.85, 13.32, 12.62, 11.85, 12.24, 13.6, 14.54, 15.65, 18.25, 18.42, 17.31, 16.42, 16.5, 16.55, 18.1, 18.14, 19.75, 20.41, 21.12, 19.91, 18.22, 18.5, 17.16, 16.23, 16.92, 17.42, 18.14, 17.02, 15.89, 14.95, 13.61, 13.94, 13.93, 14.64, 14.4, 14.22, 14.29, 14.92, 14.91, 13.43, 10.49, 10.1, 10.63, 11.56, 13.17, 13.48, 14.01, 13.4, 13.24, 13.05, 11.39, 12.47, 15.14, 15.04, 15.38, 17.74, 19.24, 26.48, 28.53, 40.29, 32.08, 33.55, 36.64, 37.2, 35.03, 33.09, 29.23, 34.53, 37.36, 37.43, 33.74, 28.86, 29.82, 33.94, 34.64, 27.86, 26.69, 23.0, 18.56, 12.73, 15.61, 14.4, 12.2, 15.95, 17.15]

    \end{Verbatim}

    \subsection{第二部分：周期性分析}\label{ux7b2cux4e8cux90e8ux5206ux5468ux671fux6027ux5206ux6790}

\begin{itemize}
\tightlist
\item
  "猪周期"，根本就是利润驱动的生猪供给周期。猪价是一种典型的周期性变化类产品，一轮大的周期大概持续4年左右，且在一年中猪价也是根据季节性不同而具有较明显的变化趋势。\\
\item
  在不考虑其他外在因素和系统性风险的前提下，其猪价主要受到生猪攻击决定，而后者主要受养殖利润驱动。\\
\item
  猪价的走势一种典型的"非线性时间序列"的数据，这种时间序列的数据具有典型的周期性，对数据按照月份进行切割并罗列，能够较明显的看出他们的这种周期特性。这里所说的周期并不是线性的周期，其相似性指的是具有更好的相关性分析结果。
\end{itemize}

    ① \textbf{历史月份切割}

    -\textgreater{}
根据所需样本数据，按照月份进行切割，这里给定切分月长度，比如：6月份作为起始点，切分月长度为12的话，那就会得到：200607\textsubscript{200706,200707}200806,...,202007\textasciitilde{}202106...。

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}5}]:} \PY{n}{SIZE} \PY{o}{=} \PY{l+m+mi}{24}   \PY{c+c1}{\PYZsh{} 月份切割尺寸}
        \PY{n}{count} \PY{o}{=} \PY{l+m+mi}{0}
        \PY{n}{tempMonthList} \PY{o}{=} \PY{p}{[}\PY{p}{]}
        \PY{n}{monthList} \PY{o}{=} \PY{p}{[}\PY{p}{]}
        \PY{n}{tempPriceList} \PY{o}{=} \PY{p}{[}\PY{p}{]}
        \PY{n}{priceList} \PY{o}{=} \PY{p}{[}\PY{p}{]}
        
        \PY{n}{dataDict} \PY{o}{=} \PY{p}{\PYZob{}}\PY{p}{\PYZcb{}}
        \PY{n}{priceDict} \PY{o}{=} \PY{p}{\PYZob{}}\PY{p}{\PYZcb{}}
        
        \PY{c+c1}{\PYZsh{} 序列整理}
        \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{dateData}\PY{p}{)}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{,} \PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{,} \PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{)}\PY{p}{:}
            \PY{n}{tempMonthList}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{dateData}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}  \PY{c+c1}{\PYZsh{} 日期序列}
            \PY{n}{tempPriceList}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{priceData}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)} \PY{c+c1}{\PYZsh{} 价格序列}
            \PY{n}{count} \PY{o}{+}\PY{o}{=} \PY{l+m+mi}{1}
            \PY{k}{if} \PY{n+nb}{len}\PY{p}{(}\PY{n}{tempMonthList}\PY{p}{)} \PY{o}{==} \PY{n}{SIZE}\PY{p}{:}
                \PY{c+c1}{\PYZsh{} print(list(reversed(tempMonthList)))}
                \PY{c+c1}{\PYZsh{} 日期序列}
                \PY{n}{monthList}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n+nb}{list}\PY{p}{(}\PY{n+nb}{reversed}\PY{p}{(}\PY{n}{tempMonthList}\PY{p}{)}\PY{p}{)}\PY{p}{)}
                \PY{n}{tempMonthList} \PY{o}{=} \PY{p}{[}\PY{p}{]}
                \PY{c+c1}{\PYZsh{} 价格序列}
                \PY{n}{priceList}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n+nb}{list}\PY{p}{(}\PY{n+nb}{reversed}\PY{p}{(}\PY{n}{tempPriceList}\PY{p}{)}\PY{p}{)}\PY{p}{)}
                \PY{n}{tempPriceList} \PY{o}{=} \PY{p}{[}\PY{p}{]}        
                \PY{n}{count} \PY{o}{=} \PY{l+m+mi}{0}
        
        \PY{n}{temp01} \PY{o}{=} \PY{p}{[}\PY{p}{]}
        \PY{n}{temp02} \PY{o}{=} \PY{p}{[}\PY{p}{]}
        \PY{c+c1}{\PYZsh{} 按照月份切割}
        \PY{k}{for} \PY{n}{m} \PY{o+ow}{in} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{01}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{02}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{03}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{04}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{05}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{06}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{07}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{08}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{09}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{10}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{11}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{12}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{:}
            \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{monthList}\PY{p}{)}\PY{p}{)}\PY{p}{:}
                \PY{c+c1}{\PYZsh{} 挑选数据}
                \PY{k}{if} \PY{n+nb}{str}\PY{p}{(}\PY{n}{monthList}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}\PY{p}{[}\PY{l+m+mi}{4}\PY{p}{:}\PY{p}{:}\PY{p}{]} \PY{o}{==} \PY{n}{m}\PY{p}{:}
                    \PY{n}{temp01}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{monthList}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)} 
                    \PY{n}{temp02}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{priceList}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}
            \PY{k}{if} \PY{n+nb}{len}\PY{p}{(}\PY{n}{temp01}\PY{p}{)} \PY{o}{!=} \PY{l+m+mi}{0}\PY{p}{:}
                \PY{c+c1}{\PYZsh{} 合并到字典}
                \PY{n}{dataDict}\PY{p}{[}\PY{n}{m} \PY{o}{+} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{月份日期开始+}\PY{l+s+s2}{\PYZdq{}} \PY{o}{+} \PY{n+nb}{str}\PY{p}{(}\PY{n}{SIZE}\PY{p}{)} \PY{o}{+} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{个月}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{temp01}
                \PY{n}{priceDict}\PY{p}{[}\PY{n}{m} \PY{o}{+} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{月份价格开始+}\PY{l+s+s2}{\PYZdq{}} \PY{o}{+} \PY{n+nb}{str}\PY{p}{(}\PY{n}{SIZE}\PY{p}{)} \PY{o}{+} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{个月}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{temp02}
                \PY{n}{temp01} \PY{o}{=} \PY{p}{[}\PY{p}{]}
                \PY{n}{temp02} \PY{o}{=} \PY{p}{[}\PY{p}{]}
        
        \PY{n+nb}{print}\PY{p}{(}\PY{n}{dataDict}\PY{o}{.}\PY{n}{keys}\PY{p}{(}\PY{p}{)}\PY{p}{)}
        \PY{n+nb}{print}\PY{p}{(}\PY{n}{priceDict}\PY{o}{.}\PY{n}{keys}\PY{p}{(}\PY{p}{)}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
dict\_keys(['12月份日期开始+24个月'])
dict\_keys(['12月份价格开始+24个月'])

    \end{Verbatim}

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}6}]:} \PY{c+c1}{\PYZsh{} print(dataDict[\PYZsq{}03月份日期数据\PYZsq{}])}
        \PY{c+c1}{\PYZsh{} for i in dataDict[\PYZsq{}06月份日期数据\PYZsq{}]:}
        \PY{c+c1}{\PYZsh{}     print(i)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}7}]:} \PY{c+c1}{\PYZsh{} print(priceDict[\PYZsq{}03月份价格数据\PYZsq{}])}
        \PY{c+c1}{\PYZsh{} for i in priceDict[\PYZsq{}03月份价格数据\PYZsq{}]:}
        \PY{c+c1}{\PYZsh{}     print(i)}
\end{Verbatim}


    ② \textbf{月份数据展示}

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}8}]:} \PY{k+kn}{import} \PY{n+nn}{matplotlib}\PY{n+nn}{.}\PY{n+nn}{pyplot} \PY{k}{as} \PY{n+nn}{plt}
        \PY{k+kn}{from} \PY{n+nn}{matplotlib}\PY{n+nn}{.}\PY{n+nn}{pyplot} \PY{k}{import} \PY{n}{MultipleLocator}
        \PY{c+c1}{\PYZsh{} 支持中文}
        \PY{n}{plt}\PY{o}{.}\PY{n}{rcParams}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{font.sans\PYZhy{}serif}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SimHei}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}  \PY{c+c1}{\PYZsh{} 用来正常显示中文标签}
        \PY{n}{plt}\PY{o}{.}\PY{n}{rcParams}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{axes.unicode\PYZus{}minus}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{k+kc}{False}  \PY{c+c1}{\PYZsh{} 用来正常显示负号}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}9}]:} \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{dataDict}\PY{o}{.}\PY{n}{keys}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{)}\PY{p}{:}
            \PY{c+c1}{\PYZsh{} 循环显示图形}
            \PY{n}{dateKey} \PY{o}{=} \PY{n+nb}{list}\PY{p}{(}\PY{n}{dataDict}\PY{o}{.}\PY{n}{keys}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{[}\PY{n}{i}\PY{p}{]}
            \PY{n}{priceKey} \PY{o}{=} \PY{n+nb}{list}\PY{p}{(}\PY{n}{priceDict}\PY{o}{.}\PY{n}{keys}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{[}\PY{n}{i}\PY{p}{]}
            
            \PY{c+c1}{\PYZsh{} 标题内容}
            \PY{n}{plt}\PY{o}{.}\PY{n}{figure}\PY{p}{(}\PY{n}{i}\PY{p}{,} \PY{n}{figsize}\PY{o}{=}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{priceDict}\PY{p}{[}\PY{n}{priceKey}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}\PY{p}{,} \PY{l+m+mi}{5}\PY{p}{)}\PY{p}{)}
            \PY{n}{plt}\PY{o}{.}\PY{n}{title}\PY{p}{(}\PY{n}{dateKey}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{4}\PY{p}{]}\PY{p}{)}
            \PY{n}{plt}\PY{o}{.}\PY{n}{tight\PYZus{}layout}\PY{p}{(}\PY{p}{)}
            \PY{c+c1}{\PYZsh{} x轴}
        \PY{c+c1}{\PYZsh{}     x = range(0, len(priceDict[priceKey][0]) \PYZhy{}1)}
            \PY{c+c1}{\PYZsh{} x轴刻度}
            \PY{n}{ax} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{gca}\PY{p}{(}\PY{p}{)}
            \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xlim}\PY{p}{(}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,} \PY{n+nb}{len}\PY{p}{(}\PY{n}{priceDict}\PY{p}{[}\PY{n}{priceKey}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
            \PY{n}{ax}\PY{o}{.}\PY{n}{xaxis}\PY{o}{.}\PY{n}{set\PYZus{}major\PYZus{}locator}\PY{p}{(}\PY{n}{MultipleLocator}\PY{p}{(}\PY{l+m+mi}{1}\PY{p}{)}\PY{p}{)}  \PY{c+c1}{\PYZsh{} 间距}
            \PY{n+nb}{print}\PY{p}{(}\PY{n}{dateKey}\PY{p}{,} \PY{n}{priceKey}\PY{p}{)}
            \PY{k}{for} \PY{n}{j} \PY{o+ow}{in} \PY{n}{priceDict}\PY{p}{[}\PY{n}{priceKey}\PY{p}{]}\PY{p}{:}
                \PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{n}{dateKey}\PY{p}{)}
                \PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{n}{priceKey}\PY{p}{)}
                \PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{j}\PY{p}{,} \PY{n}{marker}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{.}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
12月份日期开始+24个月 12月份价格开始+24个月

    \end{Verbatim}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_17_1.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    ③ \textbf{月份相关性分析}

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}10}]:} \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{dataDict}\PY{o}{.}\PY{n}{keys}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{)}\PY{p}{:}
             \PY{c+c1}{\PYZsh{} 循环显示图形}
             \PY{n}{dateKey} \PY{o}{=} \PY{n+nb}{list}\PY{p}{(}\PY{n}{dataDict}\PY{o}{.}\PY{n}{keys}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{[}\PY{n}{i}\PY{p}{]}
             \PY{n}{priceKey} \PY{o}{=} \PY{n+nb}{list}\PY{p}{(}\PY{n}{priceDict}\PY{o}{.}\PY{n}{keys}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{[}\PY{n}{i}\PY{p}{]}
             \PY{n+nb}{print}\PY{p}{(}\PY{n}{dateKey}\PY{p}{,} \PY{n}{priceKey}\PY{p}{)}
             \PY{k}{for} \PY{n}{j} \PY{o+ow}{in} \PY{n}{priceDict}\PY{p}{[}\PY{n}{priceKey}\PY{p}{]}\PY{p}{:}
                 \PY{n+nb}{print}\PY{p}{(}\PY{n}{j}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
12月份日期开始+24个月 12月份价格开始+24个月
[33.55, 36.64, 37.2, 35.03, 33.09, 29.23, 34.53, 37.36, 37.43, 33.74, 28.86, 29.82, 33.94, 34.64, 27.86, 26.69, 23.0, 18.56, 12.73, 15.61, 14.4, 12.2, 15.95, 17.15]
[14.92, 14.91, 13.43, 10.49, 10.1, 10.63, 11.56, 13.17, 13.48, 14.01, 13.4, 13.24, 13.05, 11.39, 12.47, 15.14, 15.04, 15.38, 17.74, 19.24, 26.48, 28.53, 40.29, 32.08]
[16.55, 18.1, 18.14, 19.75, 20.41, 21.12, 19.91, 18.22, 18.5, 17.16, 16.23, 16.92, 17.42, 18.14, 17.02, 15.89, 14.95, 13.61, 13.94, 13.93, 14.64, 14.4, 14.22, 14.29]
[15.38, 12.35, 11.92, 10.77, 10.55, 13.37, 13.01, 13.97, 15.35, 14.52, 13.78, 13.85, 13.32, 12.62, 11.85, 12.24, 13.6, 14.54, 15.65, 18.25, 18.42, 17.31, 16.42, 16.5]
[17.25, 17.56, 16.08, 14.77, 14.41, 13.8, 14.11, 13.88, 14.64, 14.74, 14.46, 15.31, 16.46, 17.18, 14.7, 12.77, 12.32, 13.91, 14.4, 15.09, 16.05, 15.87, 15.55, 15.77]
[12.78, 11.64, 10.35, 9.63, 10.01, 9.7, 10.37, 12.84, 12.68, 12.79, 13.44, 14.29, 13.61, 14.06, 15.04, 15.01, 15.14, 16.89, 19.61, 19.29, 19.68, 19.15, 17.49, 16.56]
[16.335, 16.819, 17.309, 17.397, 16.805, 15.84, 15.55, 14.68, 14.1, 12.15, 11.83, 12.02, 13.55, 13.386, 11.58, 10.66, 10.08, 9.59, 10.58, 11.29, 12.15, 11.92, 11.37, 12.02]

    \end{Verbatim}

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}11}]:} \PY{c+c1}{\PYZsh{} 一组数据情况}
         \PY{n}{index} \PY{o}{=} \PY{p}{[}\PY{p}{]}
         \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{dataDict}\PY{p}{[}\PY{n}{dateKey}\PY{p}{]}\PY{p}{)}\PY{p}{)}\PY{p}{:}
             \PY{n}{index}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n+nb}{str}\PY{p}{(}\PY{n}{i}\PY{p}{)} \PY{o}{+} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{组}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
         
         \PY{n}{data} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{DataFrame}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}\PY{n}{priceDict}\PY{p}{[}\PY{n}{priceKey}\PY{p}{]}\PY{p}{)}\PY{o}{.}\PY{n}{T}\PY{p}{,} \PY{n}{columns} \PY{o}{=}\PY{n}{index}\PY{p}{)}
         \PY{n}{data}
\end{Verbatim}


\begin{Verbatim}[commandchars=\\\{\}]
{\color{outcolor}Out[{\color{outcolor}11}]:}        0组     1组     2组     3组     4组     5组      6组
         0   33.55  14.92  16.55  15.38  17.25  12.78  16.335
         1   36.64  14.91  18.10  12.35  17.56  11.64  16.819
         2   37.20  13.43  18.14  11.92  16.08  10.35  17.309
         3   35.03  10.49  19.75  10.77  14.77   9.63  17.397
         4   33.09  10.10  20.41  10.55  14.41  10.01  16.805
         5   29.23  10.63  21.12  13.37  13.80   9.70  15.840
         6   34.53  11.56  19.91  13.01  14.11  10.37  15.550
         7   37.36  13.17  18.22  13.97  13.88  12.84  14.680
         8   37.43  13.48  18.50  15.35  14.64  12.68  14.100
         9   33.74  14.01  17.16  14.52  14.74  12.79  12.150
         10  28.86  13.40  16.23  13.78  14.46  13.44  11.830
         11  29.82  13.24  16.92  13.85  15.31  14.29  12.020
         12  33.94  13.05  17.42  13.32  16.46  13.61  13.550
         13  34.64  11.39  18.14  12.62  17.18  14.06  13.386
         14  27.86  12.47  17.02  11.85  14.70  15.04  11.580
         15  26.69  15.14  15.89  12.24  12.77  15.01  10.660
         16  23.00  15.04  14.95  13.60  12.32  15.14  10.080
         17  18.56  15.38  13.61  14.54  13.91  16.89   9.590
         18  12.73  17.74  13.94  15.65  14.40  19.61  10.580
         19  15.61  19.24  13.93  18.25  15.09  19.29  11.290
         20  14.40  26.48  14.64  18.42  16.05  19.68  12.150
         21  12.20  28.53  14.40  17.31  15.87  19.15  11.920
         22  15.95  40.29  14.22  16.42  15.55  17.49  11.370
         23  17.15  32.08  14.29  16.50  15.77  16.56  12.020
\end{Verbatim}
            
    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}12}]:} \PY{c+c1}{\PYZsh{} 相关系数矩阵}
         \PY{n}{corr\PYZus{}matrix} \PY{o}{=} \PY{n}{data}\PY{o}{.}\PY{n}{corr}\PY{p}{(}\PY{p}{)}
         \PY{n}{corr\PYZus{}matrix}
\end{Verbatim}


\begin{Verbatim}[commandchars=\\\{\}]
{\color{outcolor}Out[{\color{outcolor}12}]:}           0组        1组        2组        3组        4组        5组        6组
         0组  1.000000 -0.724134  0.826076 -0.718205  0.121327 -0.890397  0.711138
         1组 -0.724134  1.000000 -0.670308  0.706366  0.217439  0.669509 -0.409407
         2组  0.826076 -0.670308  1.000000 -0.712149 -0.007817 -0.916284  0.810855
         3组 -0.718205  0.706366 -0.712149  1.000000  0.174843  0.787826 -0.498164
         4组  0.121327  0.217439 -0.007817  0.174843  1.000000  0.035153  0.365808
         5组 -0.890397  0.669509 -0.916284  0.787826  0.035153  1.000000 -0.802066
         6组  0.711138 -0.409407  0.810855 -0.498164  0.365808 -0.802066  1.000000
\end{Verbatim}
            
    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}13}]:} \PY{c+c1}{\PYZsh{} 热力图数据准备}
         \PY{c+c1}{\PYZsh{} X轴和Y轴所需显示内容，就是表格中的表头,注意转接成list格式   }
         \PY{n}{axis\PYZus{}data} \PY{o}{=} \PY{n+nb}{list}\PY{p}{(}\PY{n}{corr\PYZus{}matrix}\PY{o}{.}\PY{n}{columns}\PY{p}{)}
         \PY{n}{axis\PYZus{}data}
\end{Verbatim}


\begin{Verbatim}[commandchars=\\\{\}]
{\color{outcolor}Out[{\color{outcolor}13}]:} ['0组', '1组', '2组', '3组', '4组', '5组', '6组']
\end{Verbatim}
            
    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}14}]:} \PY{c+c1}{\PYZsh{} value值}
         \PY{c+c1}{\PYZsh{} 保留小数点后两位}
         \PY{n}{temp} \PY{o}{=} \PY{p}{[}\PY{p}{]}
         \PY{n}{value} \PY{o}{=} \PY{p}{[}\PY{p}{]}
         \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{axis\PYZus{}data}\PY{p}{)}\PY{p}{)}\PY{p}{:}
             \PY{k}{for} \PY{n}{j} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{corr\PYZus{}matrix}\PY{o}{.}\PY{n}{iloc}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}\PY{p}{)}\PY{p}{:}
         \PY{c+c1}{\PYZsh{}         print(i, j , corr\PYZus{}matrix.iloc[i][j])}
                 \PY{n}{temp}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{i}\PY{p}{)}
                 \PY{n}{temp}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{j}\PY{p}{)}
                 \PY{n}{temp}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{corr\PYZus{}matrix}\PY{o}{.}\PY{n}{iloc}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{[}\PY{n}{j}\PY{p}{]}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}
                 \PY{n}{value}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{temp}\PY{p}{)}
                 \PY{n}{temp} \PY{o}{=} \PY{p}{[}\PY{p}{]}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}15}]:} \PY{c+c1}{\PYZsh{} 展示相关系数矩阵}
         \PY{c+c1}{\PYZsh{} value}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}16}]:} \PY{c+c1}{\PYZsh{} 导入pyecharts动态图标数据分析包}
         \PY{k+kn}{from} \PY{n+nn}{pyecharts} \PY{k}{import} \PY{n}{options} \PY{k}{as} \PY{n}{opts}
         \PY{k+kn}{from} \PY{n+nn}{pyecharts}\PY{n+nn}{.}\PY{n+nn}{charts} \PY{k}{import} \PY{n}{HeatMap}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}17}]:} \PY{c+c1}{\PYZsh{} Jupyter中显示}
         \PY{n}{c} \PY{o}{=} \PY{p}{(}
             \PY{n}{HeatMap}\PY{p}{(}\PY{p}{)}
             \PY{o}{.}\PY{n}{add\PYZus{}xaxis}\PY{p}{(}\PY{n}{axis\PYZus{}data}\PY{p}{)}   \PY{c+c1}{\PYZsh{} x轴的表示内容}
             \PY{o}{.}\PY{n}{add\PYZus{}yaxis}\PY{p}{(}
                 \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{相关系数矩阵}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,}
                 \PY{n}{axis\PYZus{}data}\PY{p}{,}      \PY{c+c1}{\PYZsh{} y轴的表示内容}
                 \PY{n}{value}\PY{p}{,}       \PY{c+c1}{\PYZsh{} 数值矩阵}
                 \PY{n}{label\PYZus{}opts}\PY{o}{=}\PY{n}{opts}\PY{o}{.}\PY{n}{LabelOpts}\PY{p}{(}\PY{n}{is\PYZus{}show}\PY{o}{=}\PY{k+kc}{True}\PY{p}{,} \PY{n}{position}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{inside}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}\PY{p}{,}
             \PY{p}{)}
             \PY{o}{.}\PY{n}{set\PYZus{}global\PYZus{}opts}\PY{p}{(}
                 \PY{n}{title\PYZus{}opts}\PY{o}{=}\PY{n}{opts}\PY{o}{.}\PY{n}{TitleOpts}\PY{p}{(}\PY{n}{title}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{相关系数矩阵与热力图}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}\PY{p}{,}
                 \PY{n}{visualmap\PYZus{}opts}\PY{o}{=}\PY{n}{opts}\PY{o}{.}\PY{n}{VisualMapOpts}\PY{p}{(}
                     \PY{n}{min\PYZus{}}\PY{o}{=}\PY{l+m+mi}{0}\PY{p}{,} \PY{n}{max\PYZus{}}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{,} \PY{n}{is\PYZus{}calculable}\PY{o}{=}\PY{k+kc}{True}\PY{p}{,} \PY{n}{border\PYZus{}width}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{,} \PY{n}{orient}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{vertical}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{pos\PYZus{}right}\PY{o}{=}\PY{l+m+mi}{25}\PY{p}{,} \PY{n}{pos\PYZus{}bottom}\PY{o}{=}\PY{l+m+mi}{50}
                 \PY{p}{)}\PY{p}{,}
             \PY{p}{)}
         \PY{p}{)}
         \PY{n}{c}\PY{o}{.}\PY{n}{render\PYZus{}notebook}\PY{p}{(}\PY{p}{)}
\end{Verbatim}


\begin{Verbatim}[commandchars=\\\{\}]
{\color{outcolor}Out[{\color{outcolor}17}]:} <pyecharts.render.display.HTML at 0x1783f9b8668>
\end{Verbatim}
            
    \begin{itemize}
\tightlist
\item
  经过数据分析：0-2/6、1-3/5；0/1/2/3/5/6组数据具有参考性，剔除第四组数据
\end{itemize}

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}18}]:} \PY{n}{filePrice} \PY{o}{=} \PY{p}{[}\PY{p}{]}
         \PY{n}{fileData} \PY{o}{=} \PY{p}{[}\PY{p}{]}
         
         \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{dataDict}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{12月份日期开始+24个月}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{p}{)}\PY{p}{:}
             \PY{k}{if} \PY{n}{i} \PY{o}{!=} \PY{l+m+mi}{4}\PY{p}{:}
                 \PY{n}{fileData}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{dataDict}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{12月份日期开始+24个月}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}
                 
         \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{priceDict}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{12月份价格开始+24个月}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{p}{)}\PY{p}{:}
             \PY{k}{if} \PY{n}{i} \PY{o}{!=} \PY{l+m+mi}{4}\PY{p}{:}
                 \PY{n}{filePrice}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{priceDict}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{12月份价格开始+24个月}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}
                 
         \PY{n+nb}{print}\PY{p}{(}\PY{n}{fileData}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
[[201912, 202001, 202002, 202003, 202004, 202005, 202006, 202007, 202008, 202009, 202010, 202011, 202012, 202101, 202102, 202103, 202104, 202105, 202106, 202107, 202108, 202109, 202110, 202111], [201712, 201801, 201802, 201803, 201804, 201805, 201806, 201807, 201808, 201809, 201810, 201811, 201812, 201901, 201902, 201903, 201904, 201905, 201906, 201907, 201908, 201909, 201910, 201911], [201512, 201601, 201602, 201603, 201604, 201605, 201606, 201607, 201608, 201609, 201610, 201611, 201612, 201701, 201702, 201703, 201704, 201705, 201706, 201707, 201708, 201709, 201710, 201711], [201312, 201401, 201402, 201403, 201404, 201405, 201406, 201407, 201408, 201409, 201410, 201411, 201412, 201501, 201502, 201503, 201504, 201505, 201506, 201507, 201508, 201509, 201510, 201511], [200912, 201001, 201002, 201003, 201004, 201005, 201006, 201007, 201008, 201009, 201010, 201011, 201012, 201101, 201102, 201103, 201104, 201105, 201106, 201107, 201108, 201109, 201110, 201111], [200712, 200801, 200802, 200803, 200804, 200805, 200806, 200807, 200808, 200809, 200810, 200811, 200812, 200901, 200902, 200903, 200904, 200905, 200906, 200907, 200908, 200909, 200910, 200911]]

    \end{Verbatim}

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}19}]:} \PY{n+nb}{print}\PY{p}{(}\PY{n}{filePrice}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
[[33.55, 36.64, 37.2, 35.03, 33.09, 29.23, 34.53, 37.36, 37.43, 33.74, 28.86, 29.82, 33.94, 34.64, 27.86, 26.69, 23.0, 18.56, 12.73, 15.61, 14.4, 12.2, 15.95, 17.15], [14.92, 14.91, 13.43, 10.49, 10.1, 10.63, 11.56, 13.17, 13.48, 14.01, 13.4, 13.24, 13.05, 11.39, 12.47, 15.14, 15.04, 15.38, 17.74, 19.24, 26.48, 28.53, 40.29, 32.08], [16.55, 18.1, 18.14, 19.75, 20.41, 21.12, 19.91, 18.22, 18.5, 17.16, 16.23, 16.92, 17.42, 18.14, 17.02, 15.89, 14.95, 13.61, 13.94, 13.93, 14.64, 14.4, 14.22, 14.29], [15.38, 12.35, 11.92, 10.77, 10.55, 13.37, 13.01, 13.97, 15.35, 14.52, 13.78, 13.85, 13.32, 12.62, 11.85, 12.24, 13.6, 14.54, 15.65, 18.25, 18.42, 17.31, 16.42, 16.5], [12.78, 11.64, 10.35, 9.63, 10.01, 9.7, 10.37, 12.84, 12.68, 12.79, 13.44, 14.29, 13.61, 14.06, 15.04, 15.01, 15.14, 16.89, 19.61, 19.29, 19.68, 19.15, 17.49, 16.56], [16.335, 16.819, 17.309, 17.397, 16.805, 15.84, 15.55, 14.68, 14.1, 12.15, 11.83, 12.02, 13.55, 13.386, 11.58, 10.66, 10.08, 9.59, 10.58, 11.29, 12.15, 11.92, 11.37, 12.02]]

    \end{Verbatim}

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}20}]:} \PY{c+c1}{\PYZsh{} print(file[i])}
         \PY{n}{plt}\PY{o}{.}\PY{n}{figure}\PY{p}{(}\PY{n}{figsize}\PY{o}{=}\PY{p}{(}\PY{l+m+mi}{12}\PY{p}{,} \PY{l+m+mi}{5}\PY{p}{)}\PY{p}{)}
         \PY{n}{plt}\PY{o}{.}\PY{n}{title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{观察数据}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
         \PY{n}{plt}\PY{o}{.}\PY{n}{tight\PYZus{}layout}\PY{p}{(}\PY{p}{)}
         \PY{n}{ax} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{gca}\PY{p}{(}\PY{p}{)}
         \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xlim}\PY{p}{(}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,} \PY{n}{SIZE}\PY{p}{]}\PY{p}{)}
         \PY{n}{ax}\PY{o}{.}\PY{n}{xaxis}\PY{o}{.}\PY{n}{set\PYZus{}major\PYZus{}locator}\PY{p}{(}\PY{n}{MultipleLocator}\PY{p}{(}\PY{l+m+mi}{1}\PY{p}{)}\PY{p}{)}  \PY{c+c1}{\PYZsh{} 间距}
         \PY{k}{for} \PY{n}{j} \PY{o+ow}{in} \PY{n}{filePrice}\PY{p}{:}
             \PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{j}\PY{p}{,} \PY{n}{marker}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{.}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}


    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_30_0.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \subsection{第三部分：拆分训练集和测试集并采用支持向量机回归来进行预测}\label{ux7b2cux4e09ux90e8ux5206ux62c6ux5206ux8badux7ec3ux96c6ux548cux6d4bux8bd5ux96c6ux5e76ux91c7ux7528ux652fux6301ux5411ux91cfux673aux56deux5f52ux6765ux8fdbux884cux9884ux6d4b}

\begin{itemize}
\item
\end{itemize}

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}603}]:} \PY{n}{X} \PY{o}{=} \PY{p}{[}\PY{p}{]}
          \PY{n}{y} \PY{o}{=} \PY{p}{[}\PY{p}{]}
          \PY{n}{count}  \PY{o}{=} \PY{l+m+mi}{0}
          \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{filePrice}\PY{p}{)}\PY{p}{)}\PY{p}{:}
              \PY{k}{if} \PY{n}{count} \PY{o}{==} \PY{l+m+mi}{0}\PY{p}{:}
                  \PY{n}{y} \PY{o}{=} \PY{n}{filePrice}\PY{p}{[}\PY{n}{i}\PY{p}{]}
                  \PY{n}{count} \PY{o}{+}\PY{o}{=} \PY{l+m+mi}{1}
              \PY{k}{else}\PY{p}{:}
                  \PY{n}{X}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{filePrice}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}643}]:} \PY{c+c1}{\PYZsh{} print(X)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}605}]:} \PY{n}{X} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}\PY{n}{X}\PY{p}{)}\PY{o}{.}\PY{n}{T}
          \PY{n}{X} \PY{o}{=} \PY{n}{StandardScaler}\PY{p}{(}\PY{p}{)}\PY{o}{.}\PY{n}{fit\PYZus{}transform}\PY{p}{(}\PY{n}{X}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}606}]:} \PY{n}{y} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}\PY{n}{y}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}607}]:} \PY{k+kn}{from} \PY{n+nn}{sklearn}\PY{n+nn}{.}\PY{n+nn}{model\PYZus{}selection} \PY{k}{import} \PY{n}{train\PYZus{}test\PYZus{}split}
          \PY{k+kn}{from} \PY{n+nn}{sklearn}\PY{n+nn}{.}\PY{n+nn}{svm} \PY{k}{import} \PY{n}{SVR}
          \PY{k+kn}{from} \PY{n+nn}{sklearn}\PY{n+nn}{.}\PY{n+nn}{metrics} \PY{k}{import} \PY{n}{r2\PYZus{}score}\PY{p}{,} \PY{n}{mean\PYZus{}absolute\PYZus{}error}\PY{p}{,} \PY{n}{mean\PYZus{}squared\PYZus{}error}
          
          \PY{k+kn}{import} \PY{n+nn}{matplotlib}\PY{n+nn}{.}\PY{n+nn}{pyplot} \PY{k}{as} \PY{n+nn}{plt}
          
          \PY{k+kn}{from} \PY{n+nn}{sklearn}\PY{n+nn}{.}\PY{n+nn}{preprocessing} \PY{k}{import} \PY{n}{StandardScaler}
          \PY{k+kn}{import} \PY{n+nn}{warnings}
          \PY{n}{warnings}\PY{o}{.}\PY{n}{simplefilter}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{ignore}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}608}]:} \PY{n}{Xtrain}\PY{p}{,} \PY{n}{Xtest}\PY{p}{,} \PY{n}{Ytrain}\PY{p}{,} \PY{n}{Ytest} \PY{o}{=} \PY{n}{train\PYZus{}test\PYZus{}split}\PY{p}{(}\PY{n}{X}\PY{p}{,}\PY{n}{y}\PY{p}{,} \PY{n}{test\PYZus{}size}\PY{o}{=}\PY{l+m+mf}{0.3}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}609}]:} \PY{n}{Kernel} \PY{o}{=} \PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{linear}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{poly}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{rbf}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{sigmoid}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}610}]:} \PY{k}{for} \PY{n}{kernel} \PY{o+ow}{in} \PY{n}{Kernel}\PY{p}{:}
              \PY{n}{svr} \PY{o}{=} \PY{n}{SVR}\PY{p}{(}\PY{n}{kernel}\PY{o}{=}\PY{n}{kernel}
                       \PY{p}{,}\PY{n}{gamma}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{auto}\PY{l+s+s2}{\PYZdq{}}
                       \PY{p}{,} \PY{n}{degree} \PY{o}{=}\PY{l+m+mi}{15}
                       \PY{p}{,}\PY{n}{cache\PYZus{}size}\PY{o}{=}\PY{l+m+mi}{50000}
                       \PY{p}{)}\PY{o}{.}\PY{n}{fit}\PY{p}{(}\PY{n}{Xtrain}\PY{p}{,} \PY{n}{Ytrain}\PY{p}{)}
              \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{The accuracy under kernel }\PY{l+s+si}{\PYZpc{}s}\PY{l+s+s2}{ is }\PY{l+s+si}{\PYZpc{}f}\PY{l+s+s2}{\PYZdq{}} \PY{o}{\PYZpc{}} \PY{p}{(}\PY{n}{kernel}\PY{p}{,} \PY{n}{svr}\PY{o}{.}\PY{n}{score}\PY{p}{(}\PY{n}{Xtest}\PY{p}{,} \PY{n}{Ytest}\PY{p}{)}\PY{p}{)}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
The accuracy under kernel linear is 0.713193
The accuracy under kernel poly is -133.312343
The accuracy under kernel rbf is -0.447896
The accuracy under kernel sigmoid is 0.143410

    \end{Verbatim}

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}611}]:} \PY{c+c1}{\PYZsh{} 确定核函数}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}612}]:} \PY{n}{svr} \PY{o}{=} \PY{n}{SVR}\PY{p}{(}\PY{n}{kernel}\PY{o}{=}\PY{n}{Kernel}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}  \PY{c+c1}{\PYZsh{} 选择核函数}
                   \PY{p}{,}\PY{n}{gamma}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{auto}\PY{l+s+s2}{\PYZdq{}}
                   \PY{p}{,}\PY{n}{degree} \PY{o}{=}\PY{l+m+mi}{15}
                   \PY{p}{,}\PY{n}{cache\PYZus{}size}\PY{o}{=}\PY{l+m+mi}{50000}
                   \PY{p}{)}\PY{o}{.}\PY{n}{fit}\PY{p}{(}\PY{n}{Xtrain}\PY{p}{,} \PY{n}{Ytrain}\PY{p}{)}
          
          \PY{n}{y\PYZus{}predict}\PY{o}{=}\PY{n}{svr}\PY{o}{.}\PY{n}{predict}\PY{p}{(}\PY{n}{X}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}613}]:} \PY{n}{y\PYZus{}predict}
\end{Verbatim}


\begin{Verbatim}[commandchars=\\\{\}]
{\color{outcolor}Out[{\color{outcolor}613}]:} array([30.37358211, 34.02956125, 36.57492061, 38.85626127, 38.18738606,
                 35.19530284, 34.63030289, 30.53498188, 29.01629   , 28.59545819,
                 28.75939467, 27.73339936, 29.79530992, 30.10214007, 28.52319996,
                 27.13699826, 25.79499769, 23.04866241, 18.89041318, 17.03421772,
                 14.50030205, 15.29233303, 13.85737111, 17.79922199])
\end{Verbatim}
            
    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}614}]:} \PY{c+c1}{\PYZsh{} print(\PYZsq{}svr模型自带评分机制：\PYZsq{},svr.score(Xtest,y\PYZus{}predict))}
          \PY{k+kn}{from} \PY{n+nn}{sklearn}\PY{n+nn}{.}\PY{n+nn}{metrics} \PY{k}{import} \PY{n}{r2\PYZus{}score}\PY{p}{,}\PY{n}{mean\PYZus{}squared\PYZus{}error}\PY{p}{,}\PY{n}{mean\PYZus{}absolute\PYZus{}error}
          \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{r方：}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{r2\PYZus{}score}\PY{p}{(}\PY{n}{filePrice}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,}\PY{n}{y\PYZus{}predict}\PY{p}{)}\PY{p}{)}
          \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{均方误差MSE:}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{mean\PYZus{}squared\PYZus{}error}\PY{p}{(}\PY{n}{filePrice}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,}\PY{n}{y\PYZus{}predict}\PY{p}{)}\PY{p}{)}
          \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{平均绝对误差MAE:}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{mean\PYZus{}absolute\PYZus{}error}\PY{p}{(}\PY{n}{filePrice}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,}\PY{n}{y\PYZus{}predict}\PY{p}{)}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
r方： 0.7981664707349527
均方误差MSE: 15.10156726730286
平均绝对误差MAE: 3.1069662572533363

    \end{Verbatim}

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}615}]:} \PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{y\PYZus{}predict}\PY{p}{)}
          \PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{filePrice}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}
\end{Verbatim}


\begin{Verbatim}[commandchars=\\\{\}]
{\color{outcolor}Out[{\color{outcolor}615}]:} [<matplotlib.lines.Line2D at 0x178498813c8>]
\end{Verbatim}
            
    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_44_1.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}683}]:} \PY{c+c1}{\PYZsh{} 设置预测数据}
          \PY{n}{Xpredict} \PY{o}{=} \PY{p}{[}\PY{p}{]}
          \PY{n}{count} \PY{o}{=} \PY{l+m+mi}{0}
          \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{filePrice}\PY{p}{)}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{,} \PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{,} \PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{)}\PY{p}{:}
              \PY{k}{if} \PY{n}{count} \PY{o}{!=} \PY{l+m+mi}{1}\PY{p}{:}
                  \PY{n}{Xpredict}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{filePrice}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}
              \PY{n}{count} \PY{o}{+}\PY{o}{=} \PY{l+m+mi}{1}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}684}]:} \PY{c+c1}{\PYZsh{} print(Xpredict)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}685}]:} \PY{n}{Xpredict} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}\PY{n}{Xpredict}\PY{p}{)}\PY{o}{.}\PY{n}{T}
          \PY{n}{Xpredict} \PY{o}{=} \PY{n}{StandardScaler}\PY{p}{(}\PY{p}{)}\PY{o}{.}\PY{n}{fit\PYZus{}transform}\PY{p}{(}\PY{n}{Xpredict}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}686}]:} \PY{c+c1}{\PYZsh{} Xpredict}
          \PY{n}{Ypredict} \PY{o}{=} \PY{n}{svr}\PY{o}{.}\PY{n}{predict}\PY{p}{(}\PY{n}{Xpredict}\PY{p}{)}
          \PY{c+c1}{\PYZsh{} Ypredict}
          \PY{n}{Ypredict} \PY{o}{=} \PY{n+nb}{list}\PY{p}{(}\PY{n+nb}{reversed}\PY{p}{(}\PY{n}{Ypredict}\PY{p}{)}\PY{p}{)}
\end{Verbatim}


    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}687}]:} \PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{Ypredict}\PY{p}{)}
\end{Verbatim}


\begin{Verbatim}[commandchars=\\\{\}]
{\color{outcolor}Out[{\color{outcolor}687}]:} [<matplotlib.lines.Line2D at 0x1784d858748>]
\end{Verbatim}
            
    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_50_1.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}688}]:} \PY{n}{a} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{hstack}\PY{p}{(}\PY{p}{(}\PY{n}{filePrice}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,} \PY{n}{Ypredict}\PY{p}{)}\PY{p}{)}
\end{Verbatim}


    \subsection{最终验证效果数据和展示图}\label{ux6700ux7ec8ux9a8cux8bc1ux6548ux679cux6570ux636eux548cux5c55ux793aux56fe}

    \begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}710}]:} \PY{n}{plt}\PY{o}{.}\PY{n}{figure}\PY{p}{(}\PY{n}{figsize}\PY{o}{=}\PY{p}{(}\PY{l+m+mi}{12}\PY{p}{,} \PY{l+m+mi}{5}\PY{p}{)}\PY{p}{)}
          \PY{n}{plt}\PY{o}{.}\PY{n}{title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{数据预测最终结果}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
          \PY{n}{plt}\PY{o}{.}\PY{n}{tight\PYZus{}layout}\PY{p}{(}\PY{p}{)}
          \PY{n}{ax} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{gca}\PY{p}{(}\PY{p}{)}
          \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xlim}\PY{p}{(}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,} \PY{n}{SIZE}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{]}\PY{p}{)}
          \PY{n}{ax}\PY{o}{.}\PY{n}{xaxis}\PY{o}{.}\PY{n}{set\PYZus{}major\PYZus{}locator}\PY{p}{(}\PY{n}{MultipleLocator}\PY{p}{(}\PY{l+m+mi}{1}\PY{p}{)}\PY{p}{)}  \PY{c+c1}{\PYZsh{} 间距}
          \PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{filePrice}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}
          \PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{y\PYZus{}predict}\PY{p}{)}
          \PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{a}\PY{p}{)}
          \PY{n}{plt}\PY{o}{.}\PY{n}{axvspan}\PY{p}{(}\PY{n}{xmin}\PY{o}{=}\PY{l+m+mi}{23}\PY{p}{,} \PY{n}{xmax}\PY{o}{=}\PY{l+m+mi}{48}\PY{p}{,} \PY{n}{facecolor}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{g}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{alpha}\PY{o}{=}\PY{l+m+mf}{0.3}\PY{p}{)}
          \PY{n}{plt}\PY{o}{.}\PY{n}{annotate}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{预测起点202111}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}
             \PY{n}{xy}\PY{o}{=}\PY{p}{(}\PY{l+m+mi}{23}\PY{p}{,}\PY{l+m+mf}{17.79922199}\PY{p}{)}\PY{p}{,}
             \PY{n}{xytext}\PY{o}{=}\PY{p}{(}\PY{l+m+mi}{23}\PY{p}{,}\PY{l+m+mi}{25}\PY{p}{)}\PY{p}{,}
             \PY{n}{bbox} \PY{o}{=} \PY{n+nb}{dict}\PY{p}{(}\PY{n}{boxstyle} \PY{o}{=} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{round,pad=0.5}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}
             \PY{n}{fc} \PY{o}{=} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{yellow}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{alpha} \PY{o}{=} \PY{l+m+mf}{0.5}\PY{p}{)}\PY{p}{,}
             \PY{n}{arrowprops}\PY{o}{=}\PY{n+nb}{dict}\PY{p}{(}\PY{n}{facecolor}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{red}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}
             \PY{n}{shrink}\PY{o}{=}\PY{l+m+mf}{0.05}\PY{p}{)}\PY{p}{,}\PY{n}{fontsize}\PY{o}{=}\PY{l+m+mi}{12}\PY{p}{)}
          \PY{n}{plt}\PY{o}{.}\PY{n}{annotate}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{预测终点202311}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}
             \PY{n}{xy}\PY{o}{=}\PY{p}{(}\PY{l+m+mi}{47}\PY{p}{,}\PY{l+m+mf}{25.79922199}\PY{p}{)}\PY{p}{,}
             \PY{n}{xytext}\PY{o}{=}\PY{p}{(}\PY{l+m+mi}{47}\PY{p}{,}\PY{l+m+mi}{30}\PY{p}{)}\PY{p}{,}
             \PY{n}{bbox} \PY{o}{=} \PY{n+nb}{dict}\PY{p}{(}\PY{n}{boxstyle} \PY{o}{=} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{round,pad=0.5}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}
             \PY{n}{fc} \PY{o}{=} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{yellow}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{alpha} \PY{o}{=} \PY{l+m+mf}{0.5}\PY{p}{)}\PY{p}{,}
             \PY{n}{arrowprops}\PY{o}{=}\PY{n+nb}{dict}\PY{p}{(}\PY{n}{facecolor}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{red}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}
             \PY{n}{shrink}\PY{o}{=}\PY{l+m+mf}{0.05}\PY{p}{)}\PY{p}{,}\PY{n}{fontsize}\PY{o}{=}\PY{l+m+mi}{12}\PY{p}{)}
          \PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{生猪价格}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
          \PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{月份时间轴}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\end{Verbatim}


\begin{Verbatim}[commandchars=\\\{\}]
{\color{outcolor}Out[{\color{outcolor}710}]:} Text(0.5, 26.0, '月份时间轴')
\end{Verbatim}
            
    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_53_1.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \begin{itemize}
\tightlist
\item
  预测前 24个月的实际数值：\\
  【日期】：\\
  {[}201912, 202001, 202002, 202003, 202004, 202005, 202006, 202007,
  202008, 202009, 202010, 202011, 202012, 202101, 202102, 202103,
  202104, 202105, 202106, 202107, 202108, 202109, 202110, 202111{]}\\
  【数值】filePrice{[}0{]}：\\
  {[}33.55, 36.64, 37.2, 35.03, 33.09, 29.23, 34.53, 37.36, 37.43,
  33.74, 28.86, 29.82, 33.94, 34.64, 27.86, 26.69, 23.0, 18.56, 12.73,
  15.61, 14.4, 12.2, 15.95, 17.15{]}
\end{itemize}

    \begin{itemize}
\tightlist
\item
  预测前24个月的预测数值：\\
  【日期】：\\
  {[}201912, 202001, 202002, 202003, 202004, 202005, 202006, 202007,
  202008, 202009, 202010, 202011, 202012, 202101, 202102, 202103,
  202104, 202105, 202106, 202107, 202108, 202109, 202110, 202111{]}\\
  【数值】y\_predict：\\
  {[}30.37358211 34.02956125 36.57492061 38.85626127 38.18738606
  35.19530284 34.63030289 30.53498188 29.01629 28.59545819 28.75939467
  27.73339936 29.79530992 30.10214007 28.52319996 27.13699826
  25.79499769 23.04866241 18.89041318 17.03421772 14.50030205
  15.29233303 13.85737111 17.79922199{]}
\end{itemize}

    \begin{itemize}
\tightlist
\item
  预测前24个的预测数值与实际数据的拟合效果：\\
  \textbf{r方： 0.7981664707349527}\\
  \textbf{均方误差MSE: 15.10156726730286}\\
  \textbf{平均绝对误差MAE: 3.1069662572533363}
\end{itemize}

    \begin{itemize}
\tightlist
\item
  预测后24个月的预测数据：\\
  【日期】：\\
  {[}202112\textasciitilde{}202311{]}\\
  【数值】Ypredict：\\
  {[}20.807477654891336, 17.449531077474877, 21.385698359855283,
  21.984594927736666, 27.061093736883432, 28.718693564610053,
  32.39847674608909, 32.044719456924135, 31.71550831866264,
  31.479885643005712, 30.274148132962864, 29.58935227119936,
  30.51897010466909, 31.042141880308044, 30.31763010747937,
  27.98083103826386, 28.187611113101173, 26.522391400742034,
  24.669928479168597, 26.064212385478957, 26.112974823733317,
  26.157645380551596, 25.745117442625315, 26.033374475267486{]}
\end{itemize}


    % Add a bibliography block to the postdoc
    
    
    
    \end{document}
